*****************************************************************************
*																			*
*						Analyse												*
*																			*
*****************************************************************************


use "alle Jahre zusammen/allyears_dirty.dta", clear
set more off 



* Umbennenungen
rename g_stdwn05 weight05
rename wei_ipf1w09 weight09
rename w_ipf1w13 weight13

rename latenz_pid_week2sd05 latenz_pid_2sdout05
rename latenz_pid_day2sd05 latenz_pid_2sddout05
rename latenz_wabs_week2sd05 latenz_wabs_2sdout05
rename latenz_wabs_day2sd05 latenz_wabs_2sddout05

rename latenz_pid_week3sd05 latenz_pid_out05
rename latenz_pid_day3sd05 latenz_pid_dout05
rename latenz_wabs_week3sd05 latenz_wabs_out05
rename latenz_wabs_day3sd05 latenz_wabs_dout05



foreach num in 05 09 13 {
lab var news`num' "TV-Nachrichten"
lab var internet`num' "Internet" 
}

gen week = week05 if year==2005
replace week = week09 if year==2009
replace week = week13 if year==2013
tab week year

drop if week09==-8			//zu wenige Befragte f�r 
							//wochenspezifische Analyse,
							//weil Feldzeit mittwochs begann

foreach num in 05 09 13 {
recode pidstr`num' (1/2=1) (3=2) (4=3) (5=4)
}
fre pidstr*

gen weekhelp = abs(week)
tab weekhelp

					
*------------------------------------------------------
* �bereinstimmung zwischen Wahlabsicht und PID
*-------------------------------------------------------

foreach year in 05 09 13 {
gen wabspidmatch`year' = . 
}

foreach year in 05 09 13 {
foreach num of numlist 1 4 5/7 801 {
replace wabspidmatch`year' = 1 ///
	if pid`num'`year'==1 & wabsfull`year'==`num'
replace wabspidmatch`year' = 0 ///
	if (pid`num'`year'~=1 & wabsfull`year'==`num') ///
	| (pid`num'`year'==1 & wabsfull`year'~=`num')
}
}

foreach year in 05 09 13 {
replace wabspidmatch`year' = 0 						///
	if wabsfull`year'==999 | wabsfull`year'==888	//"wei� nicht" und Nichtw�hler haben keinen Match
replace wabspidmatch`year' = . 							///
	if wabsfull`year'==. | pidunion`year'==.
lab var wabspidmatch`year' "Wahlabsicht kongruent mit PID"
}

/*
list pidunion05-pidand05 wabsfull05 wabspidmatch05 	///
	if year==2005, nolabel compress */

foreach num in 05 09 13 {
gen meanwabspidmatch`num' = .
}	

foreach num in 05 09 13 {	
	forvalues week=-10/0 {
		sum wabspidmatch`num' [aw=weight`num'] if week==`week'
		replace meanwabspidmatch`num' = r(mean) if week==`week'
	}
}


*--------------------------------------------------
* Deskriptive Kennzahlen �ber schmutzige Latenzindizes
*--------------------------------------------------


* mit 2 Standardabweichungen
estimates clear
estpost sum latenz_pid_2sdout05 dirty_latenz_pid*2sdout?? 
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzpidweek_2sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen PID-Latenzen (wochenweise)")


estpost sum latenz_pid_2sddout05 dirty_latenz_pid*2sddout*
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzpidday_2sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen PID-Latenzen (tagesweise)")
	

estpost sum latenz_wabs_2sdout05 dirty_latenz_wabs*2sdout* 
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzwabsweek_2sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Wahlabsichtslatenzen (wochenweise)")

estpost sum latenz_wabs_2sddout05 dirty_latenz_wabs*2sddout* 
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzwabsday_2sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Wahlabsichtslatenzen (tagesweise)")

estpost sum dirty_latenz_merkel_2sdout* ///
	dirty_latenz_stein_2sdout* dirty_latenz_mip_2sdout*
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtyotherweek_2sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Andere Latenzen (wochenweise)")
	
estpost sum dirty_latenz_merkel_2sddout* ///
	dirty_latenz_stein_2sddout* dirty_latenz_mip_2sddout*
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtyotherday_2sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Andere Latenzen (tagesweise)")	

* mit 3 Standardabweichungen
estimates clear
estpost sum latenz_pid_out05 dirty_latenz_pid_out?? 
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzpidweek_3sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen PID-Latenzen (wochenweise)")

estpost sum latenz_pid_dout05 dirty_latenz_pid_dout*
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzpidday_3sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen PID-Latenzen (tagesweise)")
	
estpost sum latenz_wabs_out05 dirty_latenz_wabs_out* 
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzwabsweek_3sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Wahlabsichtslatenzen (wochenweise)")

estpost sum latenz_wabs_dout05 dirty_latenz_wabs_dout* 
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtylatenzwabsday_3sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Wahlabsichtslatenzen (tagesweise)")

estpost sum dirty_latenz_merkel_out* ///
	dirty_latenz_stein_out* dirty_latenz_mip_out*
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtyotherweek_3sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Andere Latenzen (wochenweise)")
	
estpost sum dirty_latenz_merkel_dout* ///
	dirty_latenz_stein_dout* dirty_latenz_mip_dout*
esttab using "alle Jahre zusammen/Tabellen/Dirty/kennzahlen_dirtyotherday_3sd.rtf", ///
	cells("mean(label (Mittelwert) fmt(2)) sd(label(SD)) min(label(Min)) max(label(Max)) count(fmt(0) label(N))") ///
	noobs nonumbers replace ///
	title("Tabelle 2: Kennzahlen Andere Latenzen (tagesweise)")	
	

*---------------------------------------------------------
* Was erkl�rt die Latenzzeiten? Wochendummies
*---------------------------------------------------------

/*Mit marginsplot kann man nur die Werte aus dem letzten 
margins-Befehl plotten und nicht verschiedenen Graphiken
�bereinanderlegen ("overlay plot"). Deswegen diese
h�ndische L�sung*/

* 2005
estimates clear
foreach ding in pid wabs { 										
eststo: quietly reg latenz_`ding'_2sdout05 i.weekhelp ///
	[pweight=weight05]
	
margins, at(weekhelp=(0(1)5)) 	///
	vsquish post
	
mat t =J(6,3,.)											//erstelle Matrix mit 6 Zeilen und 3 Zeilen ohne Inhalt
mat list t

mat a = (0\-1\-2\-3\-4\-5)									//Werte �ber die Woche variieren soll
mat list a

forvalues i=1/6 { 										//�ber verlangte Anzahl Werte Woche
mat t[`i',1] = _b[`i'._at]								//get probability estimates
mat t[`i',2] = _b[`i'._at]-1.96*_se[`i'._at]			//lower bound
mat t[`i',3] = _b[`i'._at]+1.96*_se[`i'._at]			//upper bound
}

mat list t
mat t=t,a  												//Vektor a an Matrix drankleben
mat colnames t = pred_`ding'05 lci_`ding'05 			///
	uci_`ding'05 at_`ding'05

svmat t, names(col)										//aus Matrix einzelne Variable machen

mat list t
}

*2009
foreach ding in pid merkel stein mip wabs { 										
eststo: quietly reg dirty_latenz_`ding'_2sdout09 i.weekhelp ///
	[pweight=weight09]
		
margins, at(weekhelp=(0(1)7)) 	///
	vsquish post
	
mat t =J(8,3,.)											
mat list t

mat a = (0\-1\-2\-3\-4\-5\-6\-7)									

forvalues i=1/8{ 										
mat t[`i',1] = _b[`i'._at]								//get probability estimates
mat t[`i',2] = _b[`i'._at]-1.96*_se[`i'._at]			//lower bound
mat t[`i',3] = _b[`i'._at]+1.96*_se[`i'._at]			//upper bound
}

mat list t
mat t=t,a  												//Vektor a an Matrix drankleben
mat colnames t = pred_`ding'09 lci_`ding'09 			///
	uci_`ding'09 at_`ding'09

svmat t, names(col)										//aus Matrix einzelne Variable machen

mat list t
}

*2013
foreach ding in pid merkel stein wabs lire { 										
	eststo: quietly reg dirty_latenz_`ding'_2sdout13 i.weekhelp ///
	[pweight=weight13]
		
margins, at(weekhelp=(0(1)10)) 	///
	vsquish post
	
mat t =J(11,3,.)											
mat list t

mat a = (0\-1\-2\-3\-4\-5\-6\-7\-8\-9\-10)							
mat list a

forvalues i=1/11{ 										
mat t[`i',1] = _b[`i'._at]								//get probability estimates
mat t[`i',2] = _b[`i'._at]-1.96*_se[`i'._at]			//lower bound
mat t[`i',3] = _b[`i'._at]+1.96*_se[`i'._at]			//upper bound
}

mat list t
mat t=t,a  												//Vektor a an Matrix drankleben
mat colnames t = pred_`ding'13 lci_`ding'13 			///
	uci_`ding'13 at_`ding'13

svmat t, names(col)										//aus Matrix einzelne Variable machen

mat list t
}


*Graphik PID 
list at* in 1/11		//sind einfach immer die k ersten Beobachtungen im Datensatz
foreach num in 05  {
graph twoway (connected pred_pid`num'  			///
	at_pid13, clpattern(solid) msize(large)	///
	color(gs4)) 					///
	(line lci_pid`num' uci_pid`num' at_pid13, ///
	clpattern(dash dash) 			///
	color(gs4 gs4)), 					///
	scheme(s1mono) name(pid`num', replace) ///
	legend(order(1 "PID") position(5) ring(0) ///
	region(lwidth(none))) xtitle(" ") title("20`num'")
}

foreach num in 09 13 {
graph twoway (connected pred_pid`num'  			///
	at_pid13, clpattern(solid) msize(large)	///
	color(gs4)) 					///
	(line lci_pid`num' uci_pid`num' at_pid13, ///
	clpattern(dash dash) 			///
	color(gs4 gs4)), 					///
	scheme(s1mono) name(pid`num', replace) ///
	legend(off) ///
	xtitle(" ") title("20`num'")
}

graph combine pid05 pid09 pid13, ///
	ycommon row(1) scheme(s1mono) ///
	l1title("Latenz (Sekunden)") ///
	b1title("Wochen bis zur Bundestagswahl") ///
	title("Abbildung 2: Dynamik der 'schmutzigen' Parteiidentifikationslatenzzeiten", ///
	size(medlarge) justification(left) position(11)) ///
	note("Y-Achse: Vorhergesagte Werte aus linearer Regression der Latenzzeiten auf die Erhebungswoche mit 95%-Konfidenzintervall.", margin(medium))
graph export "alle Jahre zusammen/Graphiken/Dirty/dirty_latenzpid_timedummies.png", ///
	width(2000) height(1000) replace
	
graph drop _all

* Graphik Wahlabsicht
graph twoway (connected pred_wabs09 at_wabs13, ///
	clpattern(solid) msize(large) msymbol(S) ///
	color(gs8)) ///
	(line lci_wabs09 uci_wabs09 at_wabs13, ///
	clpattern(dash dash) color(gs8 gs8)), ///
	scheme(s1mono) name(wabs09, replace) ///
	legend(order(1 "Wahlabsicht") position(6) ///
	ring(0) col(1) region(lwidth(none))) xtitle(" ") ///
	ytitle(" ") title("2009")

foreach num in 05 13 {
graph twoway (connected pred_wabs`num' ///
	at_wabs13, clpattern(solid) ///
	msize(large) ///
	color(gs8) msymbol(S)) /// 					///
	(line lci_wabs`num' uci_wabs`num' ///
	at_wabs13, clpattern(dash dash) 			///
	color(gs8 gs8)), 					///
	scheme(s1mono) name(wabs`num', replace) ///
	legend(off) xtitle(" ") title("20`num'")
}
	
graph combine wabs05 wabs09 ///
	wabs13, ycommon scheme(s1mono) ///
	b1title("Wochen bis zur Bundestagswahl") ///
	l1title("Latenz (Sekunden)") row(1) ///
	title("Abbildung 3: Dynamik der 'schmutzigen' Wahlabsichtslatenzzeiten", ///
	size(medlarge) position(11) justification(left)) ///
	note("Y-Achse: Vorhergesagte Werte aus linearer Regression der Latenzzeiten auf die Erhebungswoche mit 95%-Konfidenzintervall.", margin(medium))
graph export ///
	"alle Jahre zusammen/Graphiken/Dirty/dirty_wabs_timedummies.png", ///
	width(2000) height(1000) replace
	
graph drop _all	
	
* Regressiontabellen
esttab est1 est3 est8 est12 est2 est7 est11 ///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_reg_latenz_pidlirewabs.rtf", ///
	replace b(2) se(2) r2(2) drop(0*) ///
	mtitle("PID 2005" "PID 2009" "PID 2013" ///
	"Links-Rechts 2013" ///
	"Wahl 2005" "Wahl 2009" "Wahl 2013") ///
	order(_cons) coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	compress note("Unstandardisierte Regressionskoeffizienten mit robsuten Standardfehlern. Daten wurden gewichtet.") ///
	title("Tabelle X: Lineare Regression der Latenzzeiten auf die Erhebungwoche")

esttab est4 est5 est6 est9 est10 ///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_reg_latenz_kandthemen.rtf", ///
	replace b(2) se(2) r2(2) drop(0*) ///
	mtitle("Merkel 2009" "Steinmeier 2009" ///
	"Problem 2009" "Merkel 2013" "Steinbr�ck 2013") ///
	order(_cons) coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	compress note("Unstandardisierte Regressionskoeffizienten mit robsuten Standardfehlern. Daten wurden gewichtet.") ///
	title("Tabelle X: Lineare Regression der Latenzzeiten auf die Erhebungwoche")

	
*--------------------------------------------------
* Interaktionen: Interindividuelle Variation
*---------------------------------------------------

estimates clear
foreach ding in pid wabs {
foreach num in 05 {
eststo: reg c.latenz_`ding'_2sdout`num' ///
	c.pidstr`num'##i.weekhelp [pweight=weight`num']
eststo: reg c.latenz_`ding'_2sdout`num' ///
	c.polint`num'##i.weekhelp [pweight=weight`num']	
}
}

foreach ding in pid wabs {
foreach num in 09 13 {
eststo: reg c.dirty_latenz_`ding'_2sdout`num' ///
	c.pidstr`num'##i.weekhelp [pweight=weight`num']
eststo: reg c.dirty_latenz_`ding'_2sdout`num' ///
	c.polint`num'##i.weekhelp [pweight=weight`num']	
}
}

eststo: reg dirty_latenz_lire_2sdout13 ///
		c.pidstr13##i.weekhelp [pweight=weight13]
eststo: reg dirty_latenz_lire_2sdout13 ///
		c.polint13##i.weekhelp [pweight=weight13]
	
* AV=Latenzen PID	
esttab est1 est2 est5 est6 est7 est8 ///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_interactions.rtf", ///
	compress b(2) se(2) r2(2) replace ///
	title("Interaktionen PID") drop(0*) ///
	coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	order(_cons 1.weekhelp 2.weekhelp 3.weekhelp ///
	4.weekhelp 5.weekhelp 6.weekhelp 7.weekhelp ///
	8.weekhelp 9.weekhelp 10.weekhelp pidstr* polint*) ///
	note("Unstandardisierte Regressionskoeffizienten mit robusten Standardfehlern. Daten wurden gewichtet.")

* AV = Latenzen Wabs
esttab est3 est4 est9 est10 est11 est12 ///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_interactions.rtf", ///
	compress b(2) se(2) r2(2) append ///
	title("Interaktionen Wahlabsicht") drop(0*) ///
	coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	order(_cons 1.weekhelp 2.weekhelp 3.weekhelp ///
	4.weekhelp 5.weekhelp 6.weekhelp 7.weekhelp ///
	8.weekhelp 9.weekhelp 10.weekhelp pidstr* polint*) ///
	note("Unstandardisierte Regressionskoeffizienten mit robusten Standardfehlern. Daten wurden gewichtet.")

* AV = latenzen Links-Rechts
esttab est13 est14 ///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_interactions.rtf", ///
	compress b(2) se(2) r2(2) append ///
	title("Interaktionen Links-Rechts-Selbsteinstufung") drop(0*) ///
	coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	order(_cons 1.weekhelp 2.weekhelp 3.weekhelp ///
	4.weekhelp 5.weekhelp 6.weekhelp 7.weekhelp ///
	8.weekhelp 9.weekhelp 10.weekhelp pidstr* polint*) ///
	note("Unstandardisierte Regressionskoeffizienten mit robusten Standardfehlern. Daten wurden gewichtet.")
		
estimates clear
eststo: reg dirty_latenz_mip_2sdout09 ///
		c.pidstr09##i.weekhelp [pweight=weight09]
eststo: reg dirty_latenz_mip_2sdout09 ///
		c.polint09##i.weekhelp [pweight=weight09]
		
foreach ding in merkel stein {
foreach num in 09 13 {
eststo: reg c.dirty_latenz_`ding'_2sdout`num' ///
	c.pidstr`num'##i.weekhelp [pweight=weight`num']
eststo: reg c.dirty_latenz_`ding'_2sdout`num' ///
	c.polint`num'##i.weekhelp [pweight=weight`num']	
}
}

esttab est1 est2		///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_interactions.rtf", ///
	compress b(2) se(2) r2(2) append ///
	title("Interaktionen Wichtigstes politisches Problem") drop(0*) ///
	coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	order(_cons 1.weekhelp 2.weekhelp 3.weekhelp ///
	4.weekhelp 5.weekhelp 6.weekhelp 7.weekhelp ///
	8.weekhelp 9.weekhelp 10.weekhelp pidstr* polint*) ///
	note("Unstandardisierte Regressionskoeffizienten mit robusten Standardfehlern. Daten wurden gewichtet.")


esttab est3 est4 est5 est6 est7 est8 est9 est10 ///	
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_interactions.rtf", ///
	compress b(2) se(2) r2(2) append ///
	title("Interaktionen Kandidatenorientierungen") drop(0*) ///
	coeflabel(_cons "Konstante" ///
	1.weekhelp "Woche 1" 2.weekhelp "Woche 2" ///
	3.weekhelp "Woche 3" 4.weekhelp "Woche 4" ///
	5.weekhelp "Woche 5" 6.weekhelp "Woche 6" ///
	7.weekhelp "Woche 7" 8.weekhelp "Woche 8" ///
	9.weekhelp "Woche 9" 10.weekhelp "Woche 10") ///
	order(_cons 1.weekhelp 2.weekhelp 3.weekhelp ///
	4.weekhelp 5.weekhelp 6.weekhelp 7.weekhelp ///
	8.weekhelp 9.weekhelp 10.weekhelp pidstr* polint*) ///
	note("Unstandardisierte Regressionskoeffizienten mit robusten Standardfehlern. Daten wurden gewichtet.")



*------------------------------------------------------
* Verhaltenskonsistenz
*-------------------------------------------------------

*Wahlabsicht
estimates clear
foreach num in 05 {
eststo: quietly logit wabspidmatch`num'  ///
	c.latenz_pid_2sdout`num' pidstr`num' ///
	polint`num' ///
	[pweight=weight`num'] if pidno`num'==0 
sum *pid_2sdout`num' if e(sample)
local a = round(r(min))
local b = round(r(max))
margins, at(c.latenz_pid_2sdout`num'=(`a'(1)`b')) ///
	asobserved 
marginsplot, scheme(s1mono) recastci(rline) ///
	ciopts(lpattern(dash)) ///
	name(wabspidmatch`num', replace) ///
	title("20`num'") xlabel(`a' 0 `b') ///
	xtitle("") ///
	ytitle("") ylabel(0.3(0.1)0.8)
}

foreach num in 09 13 {
eststo: quietly logit wabspidmatch`num'  ///
	c.dirty_latenz_pid_2sdout`num' pidstr`num' ///
	polint`num' ///
	[pweight=weight`num'] if pidno`num'==0 
sum *pid_2sdout`num' if e(sample)
local a = round(r(min))
local b = round(r(max))
margins, at(c.dirty_latenz_pid_2sdout`num'=(`a'(1)`b')) ///
	asobserved 
marginsplot, scheme(s1mono) recastci(rline) ///
	ciopts(lpattern(dash)) ///
	name(wabspidmatch`num', replace) ///
	title("20`num'") xlabel(`a' 0 `b') ///
	xtitle("") ///
	ytitle("") ylabel(0.3(0.1)0.8)
}

graph combine wabspidmatch05 wabspidmatch09 ///
	wabspidmatch13, scheme(s1mono) row(1) ///
	b1title("Latenz Parteiidentifikation") ///
	l1title("P(Wahl=Parteiidentifikation)")  ///
	note("Vorhergesagte Wahrscheinlichkeiten aus logistischer Regression mit 95%-Konfidenzintervall.", margin(medium))
graph export "alle Jahre zusammen/Graphiken/Dirty/dirty_wabspidmatch.png", width(2000) ///
	height(1000) replace
	
esttab using "alle Jahre zusammen/Tabellen/Dirty/dirty_wabspidmatch.rtf", ///
	replace mtitles("2005" "2009" "2013") nonumbers ///
	eqlabels(none) b(2) se(2) pr2(2) label ///
	title("Tabelle X: Zug�nglichkeit als Moderator der Einstellungs-Verhaltens-Konsistenz?" ///
	"Logistische Regression der �bereinstimmung zwischen Parteiidentifikation und Wahlabsicht mit schmutzigen Latenzzeiten")

* Tats�chliches Wahlverhalten
estimates clear	
foreach num in 05 {
eststo: quietly logit votepidmatch`num'  ///
	c.latenz_pid_2sdout`num' pidstr`num' ///
	polint`num' ///
	[pweight=weight`num'] if pidno`num'==0 
sum latenz_pid_2sdout`num' if e(sample)
local a = round(r(min))
local b = round(r(max))
margins, at(c.latenz_pid_2sdout`num'=(`a'(1)`b')) ///
	asobserved 
marginsplot, scheme(s1mono) recastci(rline) ///
	ciopts(lpattern(dash)) ///
	name(votepidmatch`num', replace) ///
	title("20`num'") xlabel(`a' 0 `b') ///
	xtitle("") ///
	ytitle("") ylabel(0(0.1)0.8)
}

foreach num in 09 13 {
eststo: quietly logit votepidmatch`num'  ///
	c.dirty_latenz_pid_2sdout`num' pidstr`num' ///
	polint`num' ///
	[pweight=weight`num'] if pidno`num'==0 
sum dirty_latenz_pid_2sdout`num' if e(sample)
local a = round(r(min))
local b = round(r(max))
margins, at(c.dirty_latenz_pid_2sdout`num'=(`a'(1)`b')) ///
	asobserved 
marginsplot, scheme(s1mono) recastci(rline) ///
	ciopts(lpattern(dash)) ///
	name(votepidmatch`num', replace) ///
	title("20`num'") xlabel(`a' 0 `b') ///
	xtitle("") ///
	ytitle("") ylabel(0(0.1)0.8)
}


graph combine votepidmatch05 votepidmatch09 ///
	votepidmatch13, scheme(s1mono) row(1) ///
	b1title("Latenz Parteiidentifikation") ///
	l1title("P(Wahl=Parteiidentifikation)") ///
	title("Abbildung 5: Einfluss der Parteiidentifikationszug�nglichkeit auf die Einstellungs-Verhaltens-Konsistenz (schmutzige Latenzen)", ///
	size(medlarge) justification(left) position(11)) ///
	note("Vorhergesagte Wahrscheinlichkeiten aus logistischer Regression mit 95%-Konfidenzintervall.", margin(medium))
graph export "alle Jahre zusammen/Graphiken/Dirty/dirty_votepidmatch.png", width(2000) ///
	height(1000) replace
	
graph drop _all	


esttab est1 est2 est3  ///
	using "alle Jahre zusammen/Tabellen/Dirty/dirty_votepidmatch.rtf", ///
	replace  nonumbers ///
	mtitles("2005" "2009" "2013") ///
	eqlabels(none) b(2) se(2) pr2(2) label ///
	coeflabel(latenz_pid_2sdout05 "Latenz PID" ///
	latenz_pid_2sdout09 "Latenz PID" ///
	latenz_pid_2sdout13 "Latenz PID" ///
	_cons "Konstante") /// 
	order(_cons latenz_pid_2sdout05 latenz_pid_2sdout09 ///
	latenz_pid_2sdout13 pidstr05 pidstr09 pidstr13 ///
	polint05 polint09 polint13) ///
	title("Tabelle 5: Zug�nglichkeit als Moderator der Einstellungs-Verhaltens-Konsistenz?" ///
	"Logistische Regression der �bereinstimmung zwischen Parteiidentifikation und Wahlabsicht. Schmutzige Reaktionszeiten") ///
	note("Unstandardisierte Regressionskoeffizienten mit robusten Standardfehlern.")


